import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:search_people/utils/component/component.dart';

import '../../../value/topcolors.dart';
import 'logic.dart';

class RegisterPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final logic = Get.put(RegisterLogic());
    final state = Get.find<RegisterLogic>().state;

    return Scaffold(
      backgroundColor: Colors.white,
      appBar: detailAppBar(
          context,
          title: '注册账号'
      ),
      body: Column(
        children: [

          SizedBox(height: 15.r,),
          Container(
            margin: EdgeInsets.only(left: 35.w, right: 35.w),
            child: Row(crossAxisAlignment: CrossAxisAlignment.center,mainAxisAlignment: MainAxisAlignment.center,children: [
              Container(width: 55.r,margin: EdgeInsets.only(right: 20.r,left: 5.r),child: Text('+86',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp),),),
              Expanded(child: TextField(
                decoration: InputDecoration(
                  border: InputBorder.none,
                  hintText: '请填写手机号码',
                  hintStyle: TextStyle(fontSize: 16.sp),
                ),
              )),
            ],),
          ),
          Container(
            color: TopColors.black_dd,
            height: 0.5,
            margin: EdgeInsets.fromLTRB(30.w, 1.r, 30.w, 15.h),
          ),
          Container(
            margin: EdgeInsets.only(left: 35.w, right: 35.w),
            child: Row(crossAxisAlignment: CrossAxisAlignment.center,mainAxisAlignment: MainAxisAlignment.center,children: [
              Container(width: 55.r,margin: EdgeInsets.only(right: 20.r,left: 5.r),child: Text('密码',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp),),),
              Expanded(child: TextField(
                decoration: InputDecoration(
                  border: InputBorder.none,
                  hintText: '请填写密码',
                  hintStyle: TextStyle(fontSize: 16.sp),
                ),
              )),
            ],),
          ),
          Container(
            color: TopColors.black_dd,
            height: 0.5,
            margin: EdgeInsets.fromLTRB(30.w, 1.r, 30.w, 15.h),
          ),
          Container(
            margin: EdgeInsets.only(left: 35.w, right: 35.w),
            child: Row(crossAxisAlignment: CrossAxisAlignment.center,mainAxisAlignment: MainAxisAlignment.center,children: [
              Container(width: 50.r,margin: EdgeInsets.only(right: 20.r,left: 5.r),child: Text('验证码',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp),),),
              Expanded(child: CodeField(controller: state.codeCotroller,smsClickListener: logic.registerSendSms,)),
            ],),
          ),

          GestureDetector(
              child: Container(
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(5.r)),
                    color: TopColors.main_color),
                padding: EdgeInsets.all(12.w),
                margin: EdgeInsets.fromLTRB(20.w, 40.w, 20.w, 20.w),
                child: Center(
                  child: Text(
                    '完成',
                    style: TextStyle(color: Colors.white, fontSize: 17.sp),
                  ),
                ),
              ),
              onTap: () {
                // logic.login();

                // TopImModule.init('857751635#mychat');
                // TopImModule.joinSingleRoom();
              }),
          SizedBox(height: 10.r,),
          BrnCheckbox(
            radioIndex: 0,
            // isSelected: controller.state.isAgree,
            childOnRight: true,
            mainAxisSize: MainAxisSize.min,
            child: Row(
              children: [
                Text('注册即同意',
                    style: TextStyle(
                        color: const Color.fromRGBO(0, 0, 0, 0.6),
                        fontSize: 14.sp)),
                GestureDetector(
                  child: Text('《用户协议》',
                      style: TextStyle(
                          color: TopColors.main_color, fontSize: 14.sp)),
                  onTap: () {
                    // Get.to(
                    //         () => H5Page('用户协议', UrlPath.userAgreementUrl));
                  },
                ),
                Text('和',
                    style: TextStyle(
                        color: const Color.fromRGBO(0, 0, 0, 0.6),
                        fontSize: 14.sp)),
                GestureDetector(
                  child: Text('《隐私政策》',
                      style: TextStyle(
                          color: TopColors.main_color, fontSize: 14.sp)),
                  onTap: () {
                    // Get.to(() =>
                    //     H5Page('隐私政策', UrlPath.privacyAgreementUrl));
                  },
                ),
              ],
            ),
            onValueChangedAtIndex: (index, value) {
              // controller.state.isAgree = !controller.state.isAgree;
            },
          ),
        ],
      ),
    );
  }
}
